# -*- coding: utf-8 -*-


class FileInfo(object):
    def __init__(self,name):
        self.name=name
        self.exists=False
        self.modifyTime=-1
        self.size=-1
        self.isFile=False
        self.isDir=False
        self.hash='' #file md5 hexdigest
        
class FileStore(object):
    
    def fetchInfo(self):
        raise NotImplementedError()
    
    def getChildNames(self):
        raise NotImplementedError()

    def getName(self):
        raise NotImplementedError()
    
    def makedir(self):
        raise NotImplementedError()
    
    def createFile(self,fileContent):
        '''createFile(basestring fileContent) '''
        raise NotImplementedError()
    
    def getParent(self):
        raise NotImplementedError()
    
    def getChildren(self):
        return map(lambda name: self.getChild(name),self.getChildNames())

class FileSystem(object):
    
    #abstract
    def getFileStore(self,path):
        '''getFileStore(Path path) -> FileStore'''
        raise NotImplementedError()

def register(schame,instance):
    _fileSystemInstances[schame] = instance

def getFileSystem(schame):
    assert _fileSystemInstances.has_key(schame) ,  '%s file system not find'%schame
    return _fileSystemInstances[schame]

_fileSystemInstances = {}